package com.example.javachatroomextend.mapper;

import com.example.javachatroomextend.model.Message;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface NewFriendMapper {
    @Insert("insert into new_friend values(null,#{fromId},#{fromName},#{toId},now())")
    Integer addNewFriend(@Param("fromId") Integer fromId,@Param("fromName") String fromName,@Param("toId") Integer toId);

    @Select("select fromId,fromName,toId,postTime from new_friend where toId=#{toId}")
    List<Message> getNewFriend(Integer toId);

    @Delete("delete from new_friend where fromId=#{fromId} and toId=#{toId}")
    Integer delete(@Param("fromId") Integer fromId,@Param("toId") Integer toId);

    @Select("select id from new_friend where fromId=#{fromId} and toId=#{toId}")
    Integer isExist(@Param("fromId") Integer fromId,@Param("toId") Integer toId);
}
